home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / tptc17tc.zip / SETS.PAS < prev    next >
Pascal/Delphi Source File  |  1988-03-25  |  2KB  |  57 lines

  1.  
  2. (*
  3.  * Examples of set manipulation
  4.  *
  5.  *)
  6.  
  7. program Define_Some_Sets;
  8.  
  9. type 
  10.     Goodies = (Ice_Cream,Whipped_Cream,Banana,Nuts,Cherry,
  11.                 Choc_Syrup,Strawberries,Caramel,Soda_Water,
  12.                 Salt,Pepper,Cone,Straw,Spoon,Stick);
  13.  
  14.      Treat = set of Goodies;
  15.  
  16. var  
  17.      Sundae         : Treat;
  18.      Banana_Split   : Treat;
  19.      Soda           : Treat;
  20.      Ice_Cream_Cone : Treat;
  21.      Nutty_Buddy    : Treat;
  22.      Mixed          : Treat;
  23.      Index          : byte;
  24.  
  25. begin
  26.                 (* define all ingredients used in each treat *)
  27.    Ice_Cream_Cone := [Ice_Cream,Cone];
  28.    Soda := [Straw,Soda_Water,Ice_Cream,Cherry];
  29.    Banana_Split := [Ice_Cream..Caramel];
  30.    Banana_Split := Banana_Split + [Spoon];
  31.    Nutty_Buddy := [Cone,Ice_Cream,Choc_Syrup,Nuts];
  32.    Sundae := [Ice_Cream,Whipped_Cream,Nuts,Cherry,Choc_Syrup,
  33.               Spoon];
  34.  
  35.                  (* combine for a list of all ingredients used *)
  36.  
  37.    Mixed := Ice_Cream_Cone + Soda + Banana_Split + Nutty_Buddy +
  38.             Sundae;
  39.    Mixed := [Ice_Cream..Stick] - Mixed; (* all ingredients not used *)
  40.  
  41.    if Ice_Cream     in Mixed then Writeln('Ice cream not used');
  42.    if Whipped_Cream in Mixed then Writeln('Whipped cream not used');
  43.    if Banana        in Mixed then Writeln('Bananas not used');
  44.    if Nuts          in Mixed then Writeln('Nuts are not used');
  45.    if Cherry        in Mixed then Writeln('Cherrys not used');
  46.    if Choc_Syrup    in Mixed then Writeln('Chocolate syrup not used');
  47.    if Strawberries  in Mixed then Writeln('Strawberries not used');
  48.    if Caramel       in Mixed then Writeln('Caramel is not used');
  49.    if Soda_Water    in Mixed then Writeln('Soda water is not used');
  50.    if Salt          in Mixed then Writeln('Salt not used');
  51.    if Pepper        in Mixed then Writeln('Pepper not used');
  52.    if Cone          in Mixed then Writeln('Cone not used');
  53.    if Straw         in Mixed then Writeln('Straw not used');
  54.    if Spoon         in Mixed then Writeln('Spoon not used');
  55.    if Stick         in Mixed then Writeln('Stick not used');
  56. end.
  57.